﻿using NDF.Framework.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace NDF.Framework.Web.Filters
{
    public class LoginStatusAuthorizeAttribute : NDFAuthorizeAttribute
    {
        protected override bool NDFAuthorizeCore(HttpContextBase httpContext)
        {
            return base.NDFAuthorizeCore(httpContext);
        }

        protected override bool NDFIgnoreAuthorize(AuthorizationContext filterContext)
        {
            return AuthorizeUtility.Settings.IgnoresUrl.Contains(filterContext.HttpContext.Request.Path);
        }

        protected override void NDFHandleAllowedRequest(AuthorizationContext filterContext)
        {
        }

        protected override void NDFHandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            filterContext.Result = new RedirectResult(SystemEnvironment.AuthorizeSettings.LoginUrl);
        }
    }
}
